<template>
	<view class="wrap-popup" @click.stop="onClick" @touchmove.stop.prevent>
		<view :class="mode === 'center' ? 'center' : 'bottom'">
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			/**
			 * 显示的位置
			 */
			mode: {
				type: String,
				default: "center",
			},
		},
		methods: {
			onClick(e) {
				// e.stopPropagation();
				e.preventDefault();
				this.$emit("click");
			},
		},
	};
</script>

<style lang="scss" scoped>
	.wrap-popup {
		position: fixed;
		left: 0;
		top: 0;
		width: 100vw;
		height: 100vh;
		z-index: 999;
		background-color: rgba(0, 0, 0, 0.5);

		.center {
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -80%);
			width: fit-content;
			height: fit-content;
			overflow: hidden;
			background-color: transparent;
		}

		.bottom {
			position: absolute;
			left: 50%;
			bottom: 0;
			transform: translateX(-50%);
			width: fit-content;
			height: fit-content;
			overflow: hidden;
			background-color: transparent;
		}
	}
</style>
